package com.javabasic.algorithm.leetcode;

/**
 * @author xiongmin
 * @version 0.0.1
 * @description Created by work on 2021/10/23 12:16 下午
 * @see [leetcode 492](https://leetcode-cn.com/problems/construct-the-rectangle/)
 */
public class ConstructTheRectangle {

    /**
     * 实际上就是查找差值最小的两个因数
     * @param area
     * @return
     */
    public int[] constructRectangle(int area) {
        int tag = 1;
        int markValue = 1;
        while (tag * tag <= area) {
            if (area%tag == 0) {
                markValue = tag;
            }
            tag++;
        }
        int[] result = new int[2];
        result[1] = markValue;
        if (markValue*markValue == area) {
            result[0] = markValue;
        } else {
            result[0] = area/markValue;
        }
        return result;
    }
}
